package com.educhains.module.course.service.impl;

import com.educhains.module.course.persist.mybatis.CourseChapterFileMapper;
import com.educhains.module.course.persist.mybatis.CourseChapterMapper;
import com.educhains.module.course.persist.mybatis.CourseMapper;
import com.educhains.module.course.service.CourseUploadService;
import com.educhains.module.course.vo.Course;
import com.educhains.module.course.vo.CourseChapter;
import com.educhains.module.course.vo.CourseChapterFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Iray on 2017/11/9.
 */
@Service
public class CourseUploadServiceImpl  implements CourseUploadService{

    @Autowired
    private CourseMapper courseMapper;
    @Autowired
    private CourseChapterMapper courseChapterMapper;
    @Autowired
    private CourseChapterFileMapper courseChapterFileMapper;

    public void CourseUpload(Course course) {
        courseMapper.insertSelective(course);

    }

    public void CourseChapterUpload(CourseChapter courseChapter) {
          courseChapterMapper.insertSelective(courseChapter);
    }

    public void CourseChapterFileUpload(CourseChapterFile courseChapterFile) {
        courseChapterFileMapper.insertSelective(courseChapterFile);
    }

    public Integer findChapterIdByName(String chapterName) {
        CourseChapter courseChapter = courseChapterMapper.selectByChapterName(chapterName);

        return courseChapter.getChapterId();
    }
}
